home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Portable Patmos 1.1 / patmos-src / src / crtlocal.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-19  |  1.3 KB  |  63 lines  |  [TEXT/KAHL]

  1. #include "crtlocal.h"
  2. #include <fcntl.h>
  3. #include <sys/syslimits.h>
  4. #include <string.h>
  5. #include <Events.h>
  6.  
  7. struct crt_fd_tab    crt_fd_tab[OPEN_MAX+1];
  8. long                 crt_parID;
  9. short                 crt_ioVRefNum;
  10.  
  11. static char *default_environ[] = {"LOGNAME=jrrk",NULL};
  12.  
  13. char **environ = default_environ;
  14.  
  15. int _fmode = 0;
  16.  
  17. int getdtablesize(void)
  18.     {
  19.     return OPEN_MAX;
  20.     }
  21.  
  22. int getpagesize(void)
  23.     {
  24.     return 8192;
  25.     }
  26.  
  27. char *getwd(char *fullname)
  28.     {
  29.     char *idx;
  30.     char crt_defpath[256];
  31.     OSErr err = 0;
  32.     CInfoPBRec  cPB;
  33.     cPB.dirInfo.ioDrParID = crt_parID;
  34.     crt_defpath[0] = 0;
  35.     while ((cPB.dirInfo.ioDrParID != root_parID) && !err)
  36.         {
  37.         char tmp[256];
  38.         strcpy(tmp,crt_defpath);
  39.         /* get information about dir */
  40.         cPB.hFileInfo.ioCompletion = (ProcPtr)0L;
  41.         cPB.hFileInfo.ioNamePtr = (StringPtr)crt_defpath;
  42.         cPB.hFileInfo.ioVRefNum = crt_ioVRefNum;
  43.         cPB.hFileInfo.ioFDirIndex = -1;
  44.         cPB.hFileInfo.ioDirID = cPB.dirInfo.ioDrParID;
  45.  
  46.         err = PBGetCatInfoSync(&cPB); 
  47.         strcpy(crt_defpath+1+*crt_defpath,tmp);
  48.         crt_defpath[0] = '/';
  49.         }
  50.     if (!*crt_defpath) strcpy(crt_defpath, "/");
  51.     if (fullname) strcpy(fullname, crt_defpath);
  52.     else fullname = crt_defpath;
  53.     return fullname;
  54.     }
  55.  
  56. int next_fd(int first)
  57.     {
  58.     int i;
  59.     for (i = first; i < OPEN_MAX; i++)
  60.         if (!crt_fd_tab[i].fd) return i;
  61.     }
  62.     
  63.